package com.cmw.auntapp.presenter;

import android.util.Log;

import com.cmw.auntapp.constant.API;
import com.cmw.auntapp.constant.CommandType;
import com.cmw.auntapp.core.base.BasePresenter;
import com.cmw.auntapp.core.base.IBaseView;
import com.cmw.auntapp.model.UserModel;
import java.util.HashMap;
import java.util.Map;

import static com.cmw.auntapp.constant.API.SMS_CODE_SEND;
import static com.cmw.auntapp.constant.Constant.NO_USER_AUTH_TOKEN_KEY;
import static com.cmw.auntapp.constant.Constant.NO_USER_AUTH_TOKEN_VAL_YES;

/**
 * @desc: 消息持久化业务类
 * @author: chengmingwei
 * @date: 2021/4/27 7:39 AM
 * @contact: phone(微信同号):13922111489 / email: 340360491@qq.com
 */
public class MsgPresenter extends BasePresenter<UserModel> {

    private IBaseView iBaseView;

    public MsgPresenter(IBaseView iBaseView) {
        this.iBaseView = iBaseView;
        init();
    }

    /**
     * 发送短信验证码消息
     * @param phone 手机号
     */
    public void sendSmsCode(String phone) {
        Map<String, String> params = new HashMap<>();
        params.put("phone", phone);
        params.put(NO_USER_AUTH_TOKEN_KEY, NO_USER_AUTH_TOKEN_VAL_YES);
        post(API.parseAPI(SMS_CODE_SEND, params, "phone"), params, CommandType.GET);
    }

    @Override
    protected IBaseView getView() {
        return iBaseView;
    }
}
